function ready(){
	change();
	$(".chosen-select").chosen({width: "150px;",height:"60px;"});
	$("#port_type").chosen().change(function (e, pp) {change();});
	
}


function change(){
	var port = $("#port_type").val();
	if(port == 1){
		$("#mould_type").html("");
		$("#mould_type").append("<option value=\"http同步类型\">http同步类型</option><option value=\"http异步类型\">http异步类型</option>");
		$("#mould_type").trigger("chosen:updated");
		
		
		$("#mould_type").unbind("change").change(function(){change_http();});
		$("#mould_type").unbind("change").change(function(){change_https();});
		$("#mould_type").unbind("change").change(function(){change_scoket();});
		
		$("#mould_type").chosen().change(function (e, pp) {change_http();});
		change_http();
	}else if(port == 2){
		$("#mould_type").html("");
		$("#mould_type").append("<option value=\"https同步类型\">https同步类型</option><option value=\"https异步类型\">https异步类型</option>");
		$("#mould_type").trigger("chosen:updated");
		
		$("#mould_type").unbind("change").change(function(){change_http();});
		$("#mould_type").unbind("change").change(function(){change_https();});
		$("#mould_type").unbind("change").change(function(){change_scoket();});
		
		$("#mould_type").chosen().change(function (e, pp) {change_https();});
		change_https();
	}else if(port == 3){
		$("#mould_type").html("");
		$("#mould_type").append("<option value=\"8081\">scoket短连接(8081)</option><option value=\"8082\">scoket长连接(8082)</option>");
		$("#mould_type").trigger("chosen:updated");
		
		$("#mould_type").unbind("change").change(function(){change_http();});
		$("#mould_type").unbind("change").change(function(){change_https();});
		$("#mould_type").unbind("change").change(function(){change_scoket();});
		
		//$("#mould_type").chosen().change(function (e, pp) {change_scoket();});
		change_scoket();
	}
}


function change_http(){
	var vs =$("#mould_type").val();
	//var port = $("#port_type").val();
	if(vs == 'http同步类型'){
		getSynchronousHttpMouldList();
	}else if(vs == 'http异步类型'){
		getAsynchronousHttpMouldList();
	}
}

function change_https(){
	var vs =$("#mould_type").val();
	//var port = $("#port_type").val();
	if(vs == 'https同步类型'){
		getSynchronousHttpsMouldList();
	}else if(vs == 'https异步类型'){
		getAsynchronousHttpsMouldList();
	}
}

function change_scoket(){
	var vs =$("#mould_type").val();
	//var port = $("#port_type").val();
	if(vs == '8081'){
		getScoketMouldListByport();
	}else if(vs == '8082'){
		getScoketMouldListByport();
	}
}

function change_insert(){
	var port = $("#t_port_type").val();
	if(port == 1){
		$("#t_mould_type").html("");
		$("#t_mould_type").append("<option value=\"1\">同步类型</option><option value=\"2\">异步类型</option>");
		$("#t_mould_type").trigger("chosen:updated");
		insert();
	}else if(port == 2){
		$("#t_mould_type").html("");
		$("#t_mould_type").append("<option value=\"1\">同步类型</option><option value=\"2\">异步类型</option>");
		$("#t_mould_type").trigger("chosen:updated");
		insert();
	}else if(port == 3){
		$("#t_mould_type").html("");
		$("#t_mould_type").append("<option value=\"1\">短连接(8081)</option><option value=\"2\">长连接(8082)</option>");
		$("#t_mould_type").trigger("chosen:updated");
		insert();
	}
}


function insertM(){
	//$("#t_port_type").val("1");
	//$("#t_port_type").trigger("chosen:updated");
	insert();
	//$("#t_mould_type").val("1");
	//$("#t_mould_type").trigger("chosen:updated");
	//insert();
	//document.getElementById("t_insert_serviceName").value ="";
	//document.getElementById("t_insert_url").value ="http://10.59.33.49:8080/MockPlatform/Synchronous/http/";
	//document.getElementById("t_insert_mould").value ="";
	
	$("#t_port_type").chosen().change(function (e, pp) {change_insert();});
	
	$("#t_mould_type").chosen().change(function (e, pp) {insert();});
}

/*****************************************http---同步****************************************/

function getSynchronousHttpMouldList(){
	
	var url = "/MockPlatform/Synchronous/getSynchronousHttpMouldList"
	
	$("#list").html("");
	$.ajax({
		type : "GET",
		url : encodeURI(url),
		dataType : "json",
		success : function(root) {
			$("#list").append(	"<thead><tr>"
					+"<th >id</th>"
					+"<th >业务名称</th>"
					+"<th>URL</th>"
					+"<th >操作</th>"
					+"</tr></thead>")
			tmp = root;
			$(root.synMouldList).each(
				function(i, value){
					
					$("#list").append(
							
							"<tbody><tr>"
							+"<td >"+value.id+"</td>"
							+"<td>"+value.serviceName+"</td>"
							+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.url+"</td>"
							+"<td style=\"word-break: break-all;min-width: 50px; max-width: 100px;\">" +
									"<a href=\"#t_edit\" data-toggle=\"modal\" class=\"btn btn-primary btn-mini\" onclick=\"t_update(this)\">修改</a> <a href=\"#t_del\" data-toggle=\"modal\" class=\"btn btn-danger btn-mini\" onclick=\"t_del(this)\">删除</a> </td></tr></tbody>"
					);
				});
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			$("#queryButton").attr("value", "查询").removeAttr("disabled");
			alert("查询失败，请稍后再试");
		}
	});
}


function insert(){
	var port =$("#t_port_type").val();
	var vs =$("#t_mould_type").val();
	$("#insert_html").html("");
	if(vs == 1 && port == 1){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_serviceName\"/></div>"
				+"<div>返回格式:&nbsp;<select id = \"t_insert_format\"><option value=\"xml\">xml</option><option value=\"json\">json</option><select><div>"     
				+"<div>URL名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_url\" value=\"http://10.59.33.49:8080/MockPlatform/Synchronous/http/\"/></div>"
		             +"<div>业务模板:&nbsp;<textarea style=\"width: 400px;height: 200px;\" id=\"t_insert_mould\"></textarea></div>");
		document.getElementById('insertMould').setAttribute("onclick","insertSynchronousHttpMould()");
	}else if(vs == 2 && port == 1){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_serviceName\"/></div>"
	             +" <div>第一次响应URL:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_responseUrl\" value=\"http://10.59.33.49:8080/MockPlatform/ASynchronous/http/\"/></div>"
	             +"<div>第一次响应模板:&nbsp;<textarea style=\"width: 400px;height: 100px;\" id=\"y_insert_responseMould\"></textarea>"
	             +"<div>第二次响应URL:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_receiptUrl\"/></div>"
	             +"<div>第二次响应模板:&nbsp;<textarea style=\"width: 400px;height: 100px;\" id=\"y_insert_receiptMould\"></textarea></div>")
	    document.getElementById('insertMould').setAttribute("onclick","insertAsynchronousHttpMould()");
	}else if(vs == 1 && port == 2){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_serviceName\"/></div>"
	            +"<div>加密方式：<select id = \"t_insert_encrypt\"><option value=\"1\">RSA参数加密</option><option value=\"2\">RSA全加密</option><option value=\"3\">MD5参数加密</option><select><div>" 
				+"<div>URL名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_url\" value=\"http://10.59.33.49:8080/MockPlatform/Synchronous/https/\"/></div>"
	             +"<div>业务模板:&nbsp;<textarea style=\"width: 400px;height: 200px;\" id=\"t_insert_mould\"></textarea></div>");
	document.getElementById('insertMould').setAttribute("onclick","insertSynchronousHttpsMould()");
	$("#t_insert_encrypt").chosen({width: "200px;"});
	$("#t_insert_encrypt").trigger("chosen:updated");
	}else if(vs == 2 && port == 2){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_serviceName\"/></div>"
	            +" <div>第一次响应URL:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_responseUrl\" value=\"http://10.59.33.49:8080/MockPlatform/ASynchronous/https/\"/></div>"
	            +"<div>第一次响应模板:&nbsp;<textarea style=\"width: 400px;height: 100px;\" id=\"y_insert_responseMould\"></textarea>"
	            +"<div>第二次响应URL:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_receiptUrl\"/></div>"
	            +"<div>第二次响应模板:&nbsp;<textarea style=\"width: 400px;height: 100px;\" id=\"y_insert_receiptMould\"></textarea></div>")
	   document.getElementById('insertMould').setAttribute("onclick","insertAsynchronousHttpsMould()");
	}else if(vs == 1 && port == 3){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_serviceName\"/></div>"
	             +"<div>业务接口:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_url\" value=\"http://10.59.33.49:8081/\"/></div>"
	             +"<div>业务端口:&nbsp;<input disabled=\"disabled\" style=\"width: 400px;\" type=\"text\"  id=\"t_insert_port\" value=\"8081\"/></div>"
	             +"<div>业务报文:&nbsp;<textarea style=\"width: 400px;height: 200px;\" id=\"t_insert_mould\"></textarea></div>");
	document.getElementById('insertMould').setAttribute("onclick","insertScoketMould()");
	}else if(vs == 2 && port == 3){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_serviceName\"/></div>"
	             +"<div>业务接口:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_url\" value=\"http://10.59.33.49:8082/\"/></div>"
	             +"<div>业务端口:&nbsp;<input disabled=\"disabled\" style=\"width: 400px;\" type=\"text\"  id=\"t_insert_port\" value=\"8082\"/></div>"
	             +"<div>业务报文:&nbsp;<textarea style=\"width: 400px;height: 200px;\" id=\"t_insert_mould\"></textarea></div>");
	   document.getElementById('insertMould').setAttribute("onclick","insertScoketMould()");
	}
		
	
}

function insertSynchronousHttpMould(){
	var serviceName =document.getElementById("t_insert_serviceName").value;
	var url =document.getElementById("t_insert_url").value;
	var mould =document.getElementById("t_insert_mould").value;
	var format =document.getElementById("t_insert_format").value;
	
	var url2 = "/MockPlatform/Synchronous/insertSynchronousHttpMould?serviceName="+serviceName+"&url="+url+"&mould="+mould+"&format="+format;
	if(serviceName!=""&&url!=""&&mould!=""&&format!=""){
		$.ajax({
			type: "GET",
			url : encodeURI(url2),
			dataType: "json",
			success: function (root) {
					if(root.success=="false"){
						justTip(root.name);
					}else{
						$('#t_insert').modal('hide');
						getSynchronousHttpMouldList();
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#queryButton").attr("value", "查询").removeAttr("disabled");
					alert("添加失败，请稍后再试");
				}
			});
	}else{
		alert("插入失败，请检查你输入的信息是否有误！")
	}
}

function t_update(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("t_id").value = id;
	document.getElementById('t_update_onclick').setAttribute("onclick","updateSynchronousHttpMould()");
	document.getElementById('encrypt').setAttribute("hidden","hidden");
	
	$("#t_format").chosen({width: "200px;",height:"60px;"});
	$("#t_format").trigger("chosen:updated");
	
	var url = "/MockPlatform/Synchronous/getSynchronousHttpMouldList?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
			$(root.synMouldList).each(
					function(i, value){
						document.getElementById("t_serviceName").value = value.serviceName;
						document.getElementById("t_url").value = value.url;
						document.getElementById("t_mould").value = value.mould;
						document.getElementById("t_format").value = value.format;
						$("#t_format").trigger("chosen:updated");
					})
			},
			
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}

function updateSynchronousHttpMould(){
	var id =document.getElementById("t_id").value;
	var serviceName =document.getElementById("t_serviceName").value;
	var url =document.getElementById("t_url").value;
	var mould =document.getElementById("t_mould").value;
	var format =document.getElementById("t_format").value;
	
	var url="/MockPlatform/Synchronous/updateSynchronousHttpMould?id="+id+"&serviceName="+serviceName+"&url="+url+"&mould="+mould+"&format="+format;
	
	if(serviceName!=""&&url!=""&&mould!=""&&format!=""){
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#t_edit').modal('hide');
					getSynchronousHttpMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("修改失败，请稍后再试");
			}
		});
	}else{
		alert("请检查您输入的信息！")
	}
}

function t_del(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("t_del_id").value = id;
	document.getElementById('t_del_onclick').setAttribute("onclick","delSynchronousHttpMould()");
}

function delSynchronousHttpMould(){
	var id=document.getElementById("t_del_id").value;
	var url = "/MockPlatform/Synchronous/delSynchronousHttpMould?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#t_del').modal('hide');
					getSynchronousHttpMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("删除失败，请稍后再试");
			}
		});
}





/********************************************https---同步******************************************/

function getSynchronousHttpsMouldList(){
	
	var url = "/MockPlatform/Synchronous/getSynchronousHttpsMouldList"
	
	$("#list").html("");
	$.ajax({
		type : "GET",
		url : encodeURI(url),
		dataType : "json",
		success : function(root) {
			$("#list").append(	"<thead><tr>"
					+"<th >id</th>"
					+"<th >业务名称</th>"
					+"<th>URL</th>"
					+"<th >操作</th>"
					+"</tr></thead>")
			tmp = root;
			$(root.synMouldList).each(
				function(i, value){
					
					$("#list").append(
							
							"<tbody><tr>"
							+"<td >"+value.id+"</td>"
							+"<td>"+value.serviceName+"</td>"
							+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.url+"</td>"
							+"<td style=\"word-break: break-all;min-width: 50px; max-width: 100px;\">" +
									"<a href=\"#t_edit\" data-toggle=\"modal\" class=\"btn btn-primary btn-mini\" onclick=\"t_update2(this)\">修改</a> <a href=\"#t_del\" data-toggle=\"modal\" class=\"btn btn-danger btn-mini\" onclick=\"t_del2(this)\">删除</a> </td></tr></tbody>"
					);
				});
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			$("#queryButton").attr("value", "查询").removeAttr("disabled");
			alert("查询失败，请稍后再试");
		}
	});
}


/*function insert(){
	var vs =$("#t_mould_type").val();
	$("#insert_html").html("");
	if(vs == 1){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_serviceName\"/></div>"
		             +" <div>URL名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"t_insert_url\" value=\"http://10.59.33.49:8080/MockPlatform/Synchronous/\"/></div>"
		             +"<div>业务模板:&nbsp;<textarea style=\"width: 400px;height: 200px;\" id=\"t_insert_mould\"></textarea></div>");
		document.getElementById('insertMould').setAttribute("onclick","insertSynchronousMould()");
	}else if(vs == 2){
		$("#insert_html").append("<div>业务名称:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_serviceName\"/></div>"
	             +" <div>第一次响应URL:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_responseUrl\" value=\"http://10.59.33.49:8080/MockPlatform/ASynchronous/\"/></div>"
	             +"<div>第一次响应模板:&nbsp;<textarea style=\"width: 400px;height: 100px;\" id=\"y_insert_responseMould\"></textarea>"
	             +"<div>第二次响应URL:&nbsp;<input style=\"width: 400px;\" type=\"text\"  id=\"y_insert_receiptUrl\"/></div>"
	             +"<div>第二次响应模板:&nbsp;<textarea style=\"width: 400px;height: 100px;\" id=\"y_insert_receiptMould\"></textarea></div>")
	    document.getElementById('insertMould').setAttribute("onclick","insertAsynchronousMould()");
	}
	
	
}*/

function insertSynchronousHttpsMould(){
	var serviceName =document.getElementById("t_insert_serviceName").value;
	var encrypt = document.getElementById("t_insert_encrypt").value
	var url =document.getElementById("t_insert_url").value;
	var mould =document.getElementById("t_insert_mould").value;
	
	var url2 = "/MockPlatform/Synchronous/insertSynchronousHttpsMould?serviceName="+serviceName+"&url="+url+"&mould="+mould+"&encrypt="+encrypt;
	if(serviceName!=""&&url!=""&&mould!=""&&encrypt!=""){
		$.ajax({
			type: "GET",
			url : encodeURI(url2),
			dataType: "json",
			success: function (root) {
					if(root.success=="false"){
						justTip(root.name);
					}else{
						$('#t_insert').modal('hide');
						getSynchronousHttpsMouldList();
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#queryButton").attr("value", "查询").removeAttr("disabled");
					alert("添加失败，请稍后再试");
				}
			});
	}else{
		alert("插入失败，请检查你输入的信息是否有误！")
	}
}

function t_update2(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("t_id").value = id;
	document.getElementById('t_update_onclick').setAttribute("onclick","updateSynchronousHttpsMould()");
	document.getElementById('encrypt').removeAttribute("hidden","hidden");
	$("#t_encrypt").chosen({width: "200px;",height:"60px;"});
	$("#t_encrypt").trigger("chosen:updated");
	var url = "/MockPlatform/Synchronous/getSynchronousHttpsMouldList?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
			$(root.synMouldList).each(
					function(i, value){
						var encrypt;
						if(value.encrypt == 1){
							encrypt ="RSA参数加密";
						}else if(value.encrypt == 2){
							encrypt ="RSA全加密";
						}else if(value.encrypt == 3){
							encrypt ="MD5参数加密";
						}
						
						document.getElementById("t_serviceName").value = value.serviceName;
						document.getElementById("t_encrypt").value = value.encrypt;
						document.getElementById("t_url").value = value.url;
						document.getElementById("t_mould").value = value.mould;
						$("#t_encrypt").trigger("chosen:updated");
					})
			},
			
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}

function updateSynchronousHttpsMould(){
	var id =document.getElementById("t_id").value;
	var serviceName =document.getElementById("t_serviceName").value;
	var encrypt =  $("#t_encrypt").val();
	var url =document.getElementById("t_url").value;
	var mould =document.getElementById("t_mould").value;
	
	var url="/MockPlatform/Synchronous/updateSynchronousHttpsMould?id="+id+"&serviceName="+serviceName+"&url="+url+"&mould="+mould+"&encrypt="+encrypt;
	
	if(serviceName!=""&&url!=""&&mould!=""){
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#t_edit').modal('hide');
					getSynchronousHttpsMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("修改失败，请稍后再试");
			}
		});
	}else{
		alert("请检查您输入的信息！")
	}
}

function t_del2(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("t_del_id").value = id;
	document.getElementById('t_del_onclick').setAttribute("onclick","delSynchronousHttpsMould()");
	
}

function delSynchronousHttpsMould(){
	var id=document.getElementById("t_del_id").value;
	var url = "/MockPlatform/Synchronous/delSynchronousHttpsMould?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#t_del').modal('hide');
					getSynchronousHttpsMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("删除失败，请稍后再试");
			}
		});
}









/******************************************http---异步************************************/

function getAsynchronousHttpMouldList(){
	var url = "/MockPlatform/ASynchronous/getAsynchronousHttpMouldList"
		
		$("#list").html("");
		$.ajax({
			type : "GET",
			url : encodeURI(url),
			dataType : "json",
			success : function(root) {
				$("#list").append(	"<thead><tr>"
						+"<th >id</th>"
						+"<th >业务名称</th>"
						+"<th>第一次响应URL</th>"
						+"<th>第二次响应URL</th>"
						+"<th >操作</th>"
						+"</tr></thead>")
				tmp = root;
				$(root.asynMouldList).each(
					function(i, value){
						
						$("#list").append(
								
								"<tbody><tr>"
								+"<td >"+value.id+"</td>"
								+"<td>"+value.serviceName+"</td>"
								+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.responseUrl+"</td>"
								+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.receiptUrl+"</td>"
								+"<td><a href=\"#y_edit\" data-toggle=\"modal\" class=\"btn btn-primary btn-mini\" onclick=\"y_update(this)\">修改</a> <a href=\"#y_del\" data-toggle=\"modal\" class=\"btn btn-danger btn-mini\" onclick=\"y_del(this)\">删除</a> </td></tr></tbody>"
						);
					});
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}

function insertAsynchronousHttpMould(){
	var serviceName =document.getElementById("y_insert_serviceName").value;
	var responseUrl =document.getElementById("y_insert_responseUrl").value;
	var responseMould =document.getElementById("y_insert_responseMould").value;
	var receiptUrl =document.getElementById("y_insert_receiptUrl").value;
	var receiptMould =document.getElementById("y_insert_receiptMould").value;
	
	var url2 = "/MockPlatform/ASynchronous/insertAsynchronousHttpMould?serviceName="+serviceName+"&responseUrl="+responseUrl+"&responseMould="+responseMould+"&receiptUrl="+receiptUrl+"&receiptMould="+receiptMould;
	if(serviceName!=""&&responseUrl!=""&&responseMould!=""&&receiptUrl!=""&&receiptMould!=""){
		$.ajax({
			type: "GET",
			url : encodeURI(url2),
			dataType: "json",
			success: function (root) {
					if(root.success=="false"){
						justTip(root.name);
					}else{
						$('#t_insert').modal('hide');
						getAsynchronousHttpMouldList();
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#queryButton").attr("value", "查询").removeAttr("disabled");
					alert("添加失败，请稍后再试");
				}
			});
	}else{
		alert("插入失败，请检查你输入的信息是否有误！")
	}
}


function y_update(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("y_id").value = id;
	document.getElementById('y_update_onclick').setAttribute("onclick","updateAsynchronousHttpMould()");
	
	
	var url = "/MockPlatform/ASynchronous/getAsynchronousHttpMouldList?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
			$(root.asynMouldList).each(
					function(i, value){
						document.getElementById("y_serviceName").value = value.serviceName;
						document.getElementById("y_responseUrl").value = value.responseUrl;
						document.getElementById("y_responseMould").value = value.responseMould;
						document.getElementById("y_receiptUrl").value = value.receiptUrl;
						document.getElementById("y_receiptMould").value = value.receiptMould;
					})
			},
			
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}


function updateAsynchronousHttpMould(){
	
	var id =document.getElementById("y_id").value;
	var serviceName =document.getElementById("y_serviceName").value;
	var responseUrl =document.getElementById("y_responseUrl").value;
	var responseMould =document.getElementById("y_responseMould").value;
	var receiptUrl =document.getElementById("y_receiptUrl").value;
	var receiptMould =document.getElementById("y_receiptMould").value;
	
	var url="/MockPlatform/ASynchronous/updateAsynchronousHttpMould?id="+id+"&serviceName="+serviceName+"&responseUrl="+responseUrl+"&responseMould="+responseMould+"&receiptUrl="+receiptUrl+"&receiptMould="+receiptMould;
	
	if(serviceName!=""&&responseUrl!=""&&responseMould!=""&&receiptUrl!=""&&receiptMould!=""){
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#y_edit').modal('hide');
					getAsynchronousHttpMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("修改失败，请稍后再试");
			}
		});
	}else{
		alert("请检查您输入的信息！")
	}
}


function y_del(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("y_del_id").value = id;
	document.getElementById('y_del_onclick').setAttribute("onclick","delAsynchronousHttpMould()");
}

function delAsynchronousHttpMould(){
	
	var id=document.getElementById("y_del_id").value;
	var url = "/MockPlatform/ASynchronous/delAsynchronousHttpMould?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#y_del').modal('hide');
					getAsynchronousHttpMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("删除失败，请稍后再试");
			}
		});
	
}




/***************************************https---异步****************************************/

function getAsynchronousHttpsMouldList(){
	var url = "/MockPlatform/ASynchronous/getAsynchronousHttpsMouldList"
		
		$("#list").html("");
		$.ajax({
			type : "GET",
			url : encodeURI(url),
			dataType : "json",
			success : function(root) {
				$("#list").append(	"<thead><tr>"
						+"<th >id</th>"
						+"<th >业务名称</th>"
						+"<th>第一次响应URL</th>"
						+"<th>第二次响应URL</th>"
						+"<th >操作</th>"
						+"</tr></thead>")
				tmp = root;
				$(root.asynMouldList).each(
					function(i, value){
						
						$("#list").append(
								
								"<tbody><tr>"
								+"<td >"+value.id+"</td>"
								+"<td>"+value.serviceName+"</td>"
								+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.responseUrl+"</td>"
								+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.receiptUrl+"</td>"
								+"<td><a href=\"#y_edit\" data-toggle=\"modal\" class=\"btn btn-primary btn-mini\" onclick=\"y_update2(this)\">修改</a> <a href=\"#y_del\" data-toggle=\"modal\" class=\"btn btn-danger btn-mini\" onclick=\"y_del2(this)\">删除</a> </td></tr></tbody>"
						);
					});
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}

function insertAsynchronousHttpsMould(){
	var serviceName =document.getElementById("y_insert_serviceName").value;
	var responseUrl =document.getElementById("y_insert_responseUrl").value;
	var responseMould =document.getElementById("y_insert_responseMould").value;
	var receiptUrl =document.getElementById("y_insert_receiptUrl").value;
	var receiptMould =document.getElementById("y_insert_receiptMould").value;
	
	var url2 = "/MockPlatform/ASynchronous/insertAsynchronousHttpsMould?serviceName="+serviceName+"&responseUrl="+responseUrl+"&responseMould="+responseMould+"&receiptUrl="+receiptUrl+"&receiptMould="+receiptMould;
	if(serviceName!=""&&responseUrl!=""&&responseMould!=""&&receiptUrl!=""&&receiptMould!=""){
		$.ajax({
			type: "GET",
			url : encodeURI(url2),
			dataType: "json",
			success: function (root) {
					if(root.success=="false"){
						justTip(root.name);
					}else{
						$('#t_insert').modal('hide');
						getAsynchronousHttpsMouldList();
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#queryButton").attr("value", "查询").removeAttr("disabled");
					alert("添加失败，请稍后再试");
				}
			});
	}else{
		alert("插入失败，请检查你输入的信息是否有误！")
	}
}


function y_update2(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("y_id").value = id;
	document.getElementById('y_update_onclick').setAttribute("onclick","updateAsynchronousHttpsMould()");
	
	var url = "/MockPlatform/ASynchronous/getAsynchronousHttpsMouldList?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
			$(root.asynMouldList).each(
					function(i, value){
						document.getElementById("y_serviceName").value = value.serviceName;
						document.getElementById("y_responseUrl").value = value.responseUrl;
						document.getElementById("y_responseMould").value = value.responseMould;
						document.getElementById("y_receiptUrl").value = value.receiptUrl;
						document.getElementById("y_receiptMould").value = value.receiptMould;
					})
			},
			
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}


function updateAsynchronousHttpsMould(){
	
	var id =document.getElementById("y_id").value;
	var serviceName =document.getElementById("y_serviceName").value;
	var responseUrl =document.getElementById("y_responseUrl").value;
	var responseMould =document.getElementById("y_responseMould").value;
	var receiptUrl =document.getElementById("y_receiptUrl").value;
	var receiptMould =document.getElementById("y_receiptMould").value;
	
	var url="/MockPlatform/ASynchronous/updateAsynchronousHttpsMould?id="+id+"&serviceName="+serviceName+"&responseUrl="+responseUrl+"&responseMould="+responseMould+"&receiptUrl="+receiptUrl+"&receiptMould="+receiptMould;
	
	if(serviceName!=""&&responseUrl!=""&&responseMould!=""&&receiptUrl!=""&&receiptMould!=""){
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#y_edit').modal('hide');
					getAsynchronousHttpsMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("修改失败，请稍后再试");
			}
		});
	}else{
		alert("请检查您输入的信息！")
	}
}


function y_del2(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("y_del_id").value = id;
	document.getElementById('y_del_onclick').setAttribute("onclick","delAsynchronousHttpsMould()");
}

function delAsynchronousHttpsMould(){
	
	var id=document.getElementById("y_del_id").value;
	var url = "/MockPlatform/ASynchronous/delAsynchronousHttpsMould?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#y_del').modal('hide');
					getAsynchronousHttpsMouldList();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("删除失败，请稍后再试");
			}
		});
	
}





/**************************************scoket****************************************/

function getScoketMouldListByport(){
	var port =$("#mould_type").val();
	var url = "/MockPlatform/ScoketMould/getScoketMouldListByport?port="+port;
		
		$("#list").html("");
		$.ajax({
			type : "GET",
			url : encodeURI(url),
			dataType : "json",
			success : function(root) {
				$("#list").append(	"<thead><tr>"
						+"<th >id</th>"
						+"<th >业务名称</th>"
						+"<th>ScoketURL</th>"
						+"<th>端口</th>"
						+"<th >操作</th>"
						+"</tr></thead>")
				tmp = root;
				$(root.scoketMouldList).each(
					function(i, value){
						
						$("#list").append(
								
								"<tbody><tr>"
								+"<td >"+value.id+"</td>"
								+"<td>"+value.serverName+"</td>"
								+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.url+"</td>"
								+"<td style=\"word-break: break-all;min-width: 50px; max-width: 70px;\">"+value.port+"</td>"
								+"<td><a href=\"#s_edit\" data-toggle=\"modal\" class=\"btn btn-primary btn-mini\" onclick=\"s_update2(this)\">修改</a> <a href=\"#s_del\" data-toggle=\"modal\" class=\"btn btn-danger btn-mini\" onclick=\"s_del2(this)\">删除</a> </td></tr></tbody>"
						);
					});
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}


function insertScoketMould(){
	var serviceName =document.getElementById("t_insert_serviceName").value;
	var url =document.getElementById("t_insert_url").value;
	var port =document.getElementById("t_insert_port").value;
	var mould =document.getElementById("t_insert_mould").value;
	
	var url2 = "/MockPlatform/ScoketMould/insertScoketMould?serverName="+serviceName+"&url="+url+"&port="+port+"&mould="+mould;
	if(serviceName!=""&&url!=""&&port!=""&&mould!=""){
		$.ajax({
			type: "GET",
			url : encodeURI(url2),
			dataType: "json",
			success: function (root) {
					if(root.success=="false"){
						justTip(root.name);
					}else{
						$('#t_insert').modal('hide');
						getScoketMouldListByport();
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#queryButton").attr("value", "查询").removeAttr("disabled");
					alert("添加失败，请稍后再试");
				}
			});
	}else{
		alert("插入失败，请检查你输入的信息是否有误！")
	}
}


function s_update2(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("s_id").value = id;
	
	var url = "/MockPlatform/ScoketMould/getScoketMouldById?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
			$(root.scoketMouldList).each(
					function(i, value){
						document.getElementById("s_serverName").value = value.serverName;
						document.getElementById("s_url").value = value.url;
						document.getElementById("s_port").value = value.port;
						document.getElementById("s_mould").value = value.mould;
					})
			},
			
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("查询失败，请稍后再试");
			}
		});
}


function updateScoketMould(){
	
	var id =document.getElementById("s_id").value;
	var serverName =document.getElementById("s_serverName").value;
	var url =document.getElementById("s_url").value;
	var port =document.getElementById("s_port").value;
	var mould =document.getElementById("s_mould").value;
	
	var url="/MockPlatform/ScoketMould/updateScoketMould?id="+id+"&serverName="+serverName+"&url="+url+"&port="+port+"&mould="+mould;
	
	if(serverName!=""&&url!=""&&port!=""&&mould!=""){
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#s_edit').modal('hide');
					getScoketMouldListByport();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("修改失败，请稍后再试");
			}
		});
	}else{
		alert("请检查您输入的信息！")
	}
}


function s_del2(v){
	var id=v.parentNode.previousElementSibling.previousElementSibling.previousElementSibling.previousElementSibling.innerText;
	document.getElementById("s_del_id").value = id;
}

function delScoketMould(){
	
	var id=document.getElementById("s_del_id").value;
	var url = "/MockPlatform/ScoketMould/delScoketMould?id="+id;
	
	$.ajax({
		type: "GET",
		url : encodeURI(url),
		dataType: "json",
		success: function (root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					$('#s_del').modal('hide');
					getScoketMouldListByport();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("删除失败，请稍后再试");
			}
		});
	
}


